function main() {
    var albumMeta = document.querySelector(".meta");
    var storyList = document.querySelector(".story-list");

    //1、从url中获取aid(query string)
    var aid = getParameter("aid");
    if (!aid){
        alert("必须带有 aid")
        return
    }

    var url = "/api/album-detail.json?aid=" + aid;
    ajax("get",url,function (result) {
        if (!result.success){
            alert(result.reason);
            return;
        }

        var album = result.data
        //更新meta信息
        var html = `<h1>${album.name}</h1>
                    <img src="${album.cover}">`
        albumMeta.innerHTML = html;
        //把故事列表中的故事添加到 story-list中
        for (var story of album.storyList){
            var liHtml = `<li><a href="/story-detail.html?sid=${story.sid}">
                <h3>${story.name}</h3>
                <span>${story.count}</span>
            </a></li>`
            storyList.innerHTML += liHtml;
        }
    })
}

window.addEventListener("load",main);